﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.So;
using nERP.Model.Bas;
using nERP.Model.Wms;

namespace nERP.Model.So
{
    /// <summary>
    /// 销售明细
    /// </summary>
	[Table("SaleDetail")]
    [SoftKey(nameof(SaleDetail.SaleDetailCode))]
    [Display(Name = "_Model.SaleDetail")]
    public class SaleDetail : BasePoco, ITenant
    {
        [Display(Name = "_Model._SaleDetail._Seq")]
        [Comment("序号")]
        public int? Seq { get; set; }
        [Display(Name = "_Model._SaleDetail._Sale")]
        [Comment("销售单号")]
        [NotMapped]
        public Sale Sale { get; set; }
        [Display(Name = "_Model._SaleDetail._Sale")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("销售单号")]
        public string SaleId { get; set; }
        [Display(Name = "_Model._SaleDetail._SaleDetailCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("明细单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string SaleDetailCode { get; set; }
        [Display(Name = "_Model._SaleDetail._Goods")]
        [Comment("商品")]
        [NotMapped]
        public Goods Goods { get; set; }
        [Display(Name = "_Model._SaleDetail._Goods")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("商品")]
        public string GoodsId { get; set; }
        [Display(Name = "_Model._SaleDetail._GoodsName")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("商品名称")]
        public string GoodsName { get; set; }
        [Display(Name = "_Model._SaleDetail._GoodsSpec")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("商品规格")]
        public string GoodsSpec { get; set; }
        [Display(Name = "_Model._SaleDetail._GoodsUnit")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("计量单位")]
        public string GoodsUnit { get; set; }
        [Display(Name = "_Model._SaleDetail._SaleNumber")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("数量")]
        public decimal? SaleNumber { get; set; }
        [Display(Name = "_Model._SaleDetail._UnitPrice")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("单价")]
        public decimal? UnitPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._TotalPrice")]
        [Comment("金额")]
        public decimal? TotalPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._TaxRate")]
        [Comment("税率")]
        public decimal? TaxRate { get; set; }
        [Display(Name = "_Model._SaleDetail._DiscountPrice")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("折扣金额")]
        public decimal? DiscountPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._TaxUnitPrice")]
        [Comment("含税单价")]
        public decimal? TaxUnitPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._TaxPrice")]
        [Comment("税额")]
        public decimal? TaxPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._TotalTaxPrice")]
        [Comment("含税金额")]
        public decimal? TotalTaxPrice { get; set; }
        [Display(Name = "_Model._SaleDetail._Status")]
        [Comment("状态")]
        public dStatusTypeEnum? Status { get; set; } = dStatusTypeEnum.Unaudited;
        [Display(Name = "_Model._SaleDetail._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._SaleReturnDetail._SaleDetail")]
        [InverseProperty("SaleDetail")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.So.SaleReturnDetail.SaleDetailId))]
        public List<SaleReturnDetail> SaleReturnDetail_SaleDetail { get; set; }
        [Display(Name = "_Model._SaleOutWarehouseDetail._SaleDetail")]
        [InverseProperty("SaleDetail")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.SaleOutWarehouseDetail.SaleDetailId))]
        public List<SaleOutWarehouseDetail> SaleOutWarehouseDetail_SaleDetail { get; set; }
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

    }

}
